package com.yunhe.history.config;

import com.yunhe.history.constant.InfluxDBConsts;
import com.yunhe.history.util.InfluxDBConnection;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * InfluxDB配置类
 * @author liuronglei
 */
@Configuration
public class InfluxDBConfig {

    @Value("${influxdb.url}")
    private String dbUrl;

    @Value("${influxdb.username}")
    private String username;

    @Value("${influxdb.password}")
    private String password;

    @Bean
    public InfluxDBConnection getInfluxDBConnection() {
        String database = InfluxDBConsts.DATABASE;
        String retentionPolicy = InfluxDBConsts.RETENTION_POLICY;
        return new InfluxDBConnection(username,
                password, dbUrl, database, retentionPolicy);
    }
}
